/********************************************/
/*	Copyright (C) 2018 Gong Li Bin			*/
/*	Project:	GmRm2000-1.0.0				*/
/*	Author:		gong_libin					*/
/*	Date:		2018_07_01					*/
/*	File:		GmMac.go					*/
/********************************************/

package proto

import (
	"fmt"
	"encoding/binary"
)

const (
	ETHTYPE_IP		= 0x0800
	ETHTYPE_ARP		= 0x0806
	ETHTYPE_VLAN	= 0x8100
	ETHTYPE_IPV6	= 0x86dd
)

type GmMac struct {
	EtherDHost	[]byte
	EtherSHost	[]byte
	EtherType	uint16
}

func NewGmMac(buf []byte) *GmMac {
	return &GmMac{EtherDHost: buf[0:6], EtherSHost: buf[6:12], EtherType: uint16(binary.BigEndian.Uint16(buf[12:14]))}
}

func (v GmMac)GmPrint() {
	fmt.Printf("MacSrc: %02x:%02x:%02x:%02x:%02x:%02x, ", v.EtherSHost[0], v.EtherSHost[1], v.EtherSHost[2], v.EtherSHost[3], v.EtherSHost[4], v.EtherSHost[5])
	fmt.Printf("MacDst: %02x:%02x:%02x:%02x:%02x:%02x, ", v.EtherDHost[0], v.EtherDHost[1], v.EtherDHost[2], v.EtherDHost[3], v.EtherDHost[4], v.EtherDHost[5])
	fmt.Printf("MacType: 0x%04x\n", v.EtherType)
}